How to swap Two integers variable values without using a third variable?
Swap Two integers variable values without using the third variable.
547
02-Feb-2023
Updated on 15-Jun-2023
Aryan Kumar
15-Jun-2023Sure, here is a C# code that swaps two integers without using a third variable:
C#
This code works by adding x and y together, then storing the result in x. Then, it subtracts y from the result, and stores the result in y. Finally, it subtracts x from the result, and stores the result in x. This effectively swaps the values of x and y without using a third variable.
Here is an explanation of how the code works:
Ravi Vishwakarma
05-Feb-2023There is a simple C# program to swap to an integer without using a third variable.